﻿using System;
using System.Diagnostics;
using System.Reflection;
using System.Windows.Input;
using Wen.Core;

namespace Wen.UI.Main
{
	internal class AboutViewModel : ViewModel
	{
		private string _applicationVersion;
		public string ApplicationVersion {
			get {
				if (string.IsNullOrEmpty(_applicationVersion)) {
					Assembly assembly = Assembly.GetExecutingAssembly();
					Version version = assembly.GetName().Version;
					_applicationVersion = String.Format("{0}.{1}", version.Major, version.Minor);
				}
				return _applicationVersion;
			}
		}

		public ICommand OpenLinkCommand { get; private set; }

		internal AboutViewModel() {
			OpenLinkCommand = new SimpleCommand<Uri>(OnLinkCommandImpl);
		}

		private void OnLinkCommandImpl(Uri uri) {
			Process.Start(new ProcessStartInfo(uri.AbsoluteUri));
		}
	}
}
